<script>
    jQuery(function ($) {
        var orgBsSuggest = $(".OrgBsSuggest").bsSuggest({
            idField: 'orgId', //data.value 的第几个数据，作为input输入框的内容
            keyField: 'orgName', //data.value 的第几个数据，作为input输入框的内容
            allowNoKeyword: false, //是否允许无关键字时请求数据
            multiWord: true,
            separator: ",",
            getDataMethod: "url",
            effectiveFieldsAlias: {
                orgId: "机构ID",
                orgCode: "机构编号",
                orgName: "机构名称",
                orgPhone: "机构手机"
            },
            showHeader: true,
            url: '/user/org/suggest?sv=',
            processData: function (json) {
                var i, len, data = {
                    value: []
                };
                if (!json || !json.result || json.result.length == 0) {
                    return false;
                }
                len = json.result.length;
                for (i = 0; i < len; i++) {
                    data.value.push({
                        "orgId": json.result[i].id,
                        "orgCode": json.result[i].code,
                        "orgName": json.result[i].name,
                        "orgPhone": json.result[i].phone
                    });
                }
                return data;
            }
        }).on('onSetSelectValue', function (e, keyword) {
            var refObj = $(this).attr("refId");
            $(refObj).val(keyword.id);
        }).on('onUnsetSelectValue', function (e) {
            console.log("onUnsetSelectValue");
        });
        $(".ClearOrgBsSuggest").on("click", function () {
            var refObj = $(this).attr("refObj");
            $(refObj).val("");
            var refId = $(refObj).attr("refId");
            $(refId).val("");
        });
    });
</script>